home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / demo / client / scripts / sceneGui.cs < prev    next >
Encoding:
Text File  |  2005-11-23  |  2.2 KB  |  83 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine 
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5.  
  6. //-----------------------------------------------------------------------------
  7. // SceneGui is the main TSControl through which the demo is viewed.
  8. // The SceneGui also contains the hud controls.
  9. //-----------------------------------------------------------------------------
  10.  
  11. function SceneGui::onWake(%this)
  12. {
  13.    // Turn off any shell sounds...
  14.    // alxStop( ... );
  15.  
  16.    $enableDirectInput = "1";
  17.    activateDirectInput();
  18.  
  19.    // Update the action map
  20.    moveMap.push();
  21.  
  22.    // Push the menu system
  23.    OverlayBuyNow.setVisible(false);
  24.    Canvas.pushdialog(OverlayDlg);
  25. }
  26.  
  27. function SceneGui::onSleep(%this)
  28. {
  29.    // pop the keymaps
  30.    moveMap.pop();
  31. }
  32.  
  33. function SceneGui::isNextScene(%this)
  34. {
  35.    return %this.sceneNumber < ("MissionGroup/Scenes".getCount() - 1);
  36. }
  37.  
  38. function SceneGui::isPrevScene(%this)
  39. {
  40.    return %this.sceneNumber > 0;
  41. }
  42.  
  43. function SceneGui::setSceneNumber(%this,%sceneNumber)
  44. {
  45.    // Set the current room # and update the arrows
  46.    %this.sceneNumber = %sceneNumber;
  47.    
  48.    // Update the navigation buttons
  49.    OverlayNextPage.setVisible(true);
  50.    OverlayNextPage.command = %this.isNextScene()? "SceneGui.nextScene();" : "escapeFromGame();";
  51.    OverlayPrevPage.setVisible(true); //%this.isPrevScene());
  52.    OverlayPrevPage.command = "SceneGui.prevScene();";
  53.    OverlayQuitPage.setVisible(false);
  54.  
  55.    // Activate the scene object
  56.    %room = Scene::activateScene(%this.sceneNumber);
  57.  
  58.    // Extract demo text from room object
  59.    OverlayTitle.setText(
  60.       "<just:center><shadowcolor:000000><shadow:1:1>" @
  61.       %room.title);
  62.    OverlayDesc.setText(
  63.       "<font:Arial Bold:18><color:ffffff>" @
  64.       %room.description);
  65. }
  66.  
  67. function SceneGui::nextScene(%this)
  68. {
  69.    if (%this.isNextScene())
  70.       %this.setSceneNumber(%this.sceneNumber + 1);
  71. }
  72.  
  73. function SceneGui::prevScene(%this)
  74. {
  75.    if (%this.isPrevScene())
  76.       %this.setSceneNumber(%this.sceneNumber - 1);
  77.    else
  78.       escapeFromGame();
  79. }
  80.  
  81.  
  82.  
  83.